package cn.edu.bzu.manager.computer.controller;

import cn.edu.bzu.manager.computer.entity.GpuBrand;
import cn.edu.bzu.manager.computer.entity.GpuInfo;
import cn.edu.bzu.manager.computer.service.GpuService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 显卡控制器
 *
 * @author 1923111015张铭宸
 * @since 1.8
 */

@RestController
@AllArgsConstructor
@RequestMapping("/gpu")
public class GpuController {

    private final GpuService gpuService;

    @GetMapping("/all")
    public List<GpuInfo> showAllGpuInfos() {
        return gpuService.findAllGpuInfos();
    }

    @DeleteMapping("/{id}")
    public void deleteGpuInfo(@PathVariable Integer id) {
        gpuService.deleteGpuInfoById(id);
    }

    @GetMapping("/brand/all")
    public List<GpuBrand> showAllGpuBrands() {
        return gpuService.findAllGpuBrands();
    }

    @PutMapping("/brand/{id}")
    public void updateBrand(@RequestBody GpuBrand gpuBrand) {
        gpuService.saveGpuBrand(gpuBrand);
    }

    @DeleteMapping("/brand/{id}")
    public void deleteGpuBrandById(@PathVariable Integer id) {
        gpuService.deleteGpuBrandById(id);
    }

    @PostMapping("/")
    public void saveGpuInfo(@RequestBody GpuInfo gpuInfo) {
        gpuService.saveGpuInfo(gpuInfo);
    }

}
